package com.signway.javaui.slice.component;

import com.signway.javaui.ResourceTable;
import com.signway.javaui.base.BaseAbilitySlice;
import com.signway.javaui.utils.SwLog;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Rating;
import ohos.agp.components.element.PixelMapElement;

public class ProgressComponent extends BaseAbilitySlice {
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_component_progress);

        Rating rating = (Rating) findComponentById(ResourceTable.Id_rating_sec);
        rating.setGrainSize(0.5f);/* 最小控制粒度 */
        rating.setScore(3.5f);/* 评级分数 */
        rating.setIsOperable(false);/* 允许交互 */

        try {
//            ShapeElement filledElement = new ShapeElement();
//            filledElement.setShaderType(ShapeElement.OVAL);
//            filledElement.setRgbColor(new RgbColor(255, 0, 0));
//
//            ShapeElement halfElement = new ShapeElement();
//            halfElement.setShaderType(ShapeElement.OVAL);
//            halfElement.setRgbColor(new RgbColor(0, 255, 0));
//
//            ShapeElement unFilledElement = new ShapeElement();
//            unFilledElement.setShaderType(ShapeElement.OVAL);
//            unFilledElement.setRgbColor(new RgbColor(0, 0, 255));
//
//            rating.setFilledElement(filledElement);
//            rating.setHalfFilledElement(halfElement);
//            rating.setUnfilledElement(unFilledElement);

            rating.setFilledElement(new PixelMapElement(getResourceManager().getResource(ResourceTable.Media_ic_star_filled)));
            rating.setHalfFilledElement(new PixelMapElement(getResourceManager().getResource(ResourceTable.Media_ic_star_halffilled)));
            rating.setUnfilledElement(new PixelMapElement(getResourceManager().getResource(ResourceTable.Media_ic_star_unfilled)));
        } catch (Exception e) {
            SwLog.error(e.toString());
        }
    }
}
